<?php

require_once __DIR__ . '/../Locale.php'; // only needed for PHPUnit

class Rsj_Locale_Intl extends Rsj_Locale
{
    /**
     *
     *
     * @assert () === 'PHP_intl Locale'
     */
    public function getTypeOfLocaleProcessor()
    {
        return "PHP_intl Locale";
    }

    /**
     *
     *
     * @assert ('ja_JP') === 'Japan'
     * @assert ('en_US') === 'United States'
     * @assert ('sl-Latn-IT-nedis') === 'Italy'
     */
    public function getDisplayRegion( $regionCode )
    {
        return \Locale::getDisplayRegion( $regionCode, $this->_locale );
    }

    /**
     *
     *
     * @assert ('en') === 'English'
     * @assert ('ja_JP') === 'Japanese'
     * @return formatted region name
     */
    public function getDisplayLanguage( $languageCode )
    {
        return \Locale::getDisplayLanguage( $languageCode, $this->_locale );
    }

    /**
     *
     *
     * @assert ('12345', 'USD') === '$12,345.00'
     * @assert ('6789', 'JPY') === '\\6,789'
     * @return formatted price with currency
     */
    public function formatCurrency( $value, $currency, $type = NumberFormatter::CURRENCY )
    {
        $formatter = new NumberFormatter( $this->_locale, $type );

        return $formatter->formatCurrency( $value, $currency );
    }

    /**
     *
     *
     * @assert ('12345') === '12345'
     * @assert ('6789') === '6789'
     */
    public function format( $value, $type = NumberFormatter::TYPE_DEFAULT )
    {
        $formatter = new NumberFormatter( $this->_locale, $type );

        return $formatter->format( $value, $type );
    }

}
